//#include "GlobalSocket.h"
//#include "Data.h"
#include "PrivateChatDialog.h"
//#include <vector>
using namespace std;
#pragma once
#define WM_SOCKET WM_USER+2

// CChatRoomDialog dialog

class CChatRoomDialog : public CDialog
{
	DECLARE_DYNAMIC(CChatRoomDialog)

public:
	CChatRoomDialog(CWnd* pParent = NULL);   // standard constructor
	virtual ~CChatRoomDialog();

// Dialog Data
	enum { IDD = IDD_CHATROOM_DIALOG };
//**************************************<<
	//CGlobalSocket globalSock
	int sendType;
	CString sUsername;//username
	CString sReceivedMessage;//message nhan duoc
	int buffLength; //chieu dai message nhan
	SOCKET sClient; 
	int WMSOCKET;
	bool isConnected;
	CGlobalSocket *globalSock;
	CListBox *pListUsers, *pListMessages;
	CEdit *pSend;
	bool initRoom(CString sUsername,CGlobalSocket *gSock);
	bool setWMSOCKET(int WMSOCKET);
	LRESULT SockMsg(WPARAM wParam,LPARAM lParam);
	LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
	int sendPackage(CString package);
	int createPackage(int code);
	void choseAction(vector<CString> arrReceivePackage);
	void chatRoom(PACKAGE pack);
	int findUser(CString sUserOffline);
	bool deleteUser(CString sUserOffline);
	BOOL PreTranslateMessage(MSG* pMsg);
	PACKAGE parseMessage(vector<CString> arrCode);

	// Chat Private 
	// variable
	vector <CPrivateChatDialog *> arrPrivateChatDlgs;
	vector <CString> arrPrivateUsers;


	// method
	CString registerPrivateChat ();
	int findPrivateUser (CString user);

	
//**************************************>>
protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	virtual BOOL OnInitDialog();

	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedBtnSendMessage();
	afx_msg void OnBnClickedBtnPrivateChat();
	afx_msg void OnBnClickedBtnSendFile();
	afx_msg void OnLbnDblclkListUsers();
	afx_msg void OnClose();
};
